<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html>
<html lang="en">
<head>
	<base href="<%=basePath%>">
	<meta charset="utf-8" />
	<meta name="viewport" content="width=device-width, initial-scale=1.0" />
	<!-- basic styles -->
	<link rel="stylesheet" href="assets/css/bootstrap.min.css" />
	<link rel="stylesheet" href="assets/css/bootstrap-responsive.min.css" />
	<link rel="stylesheet" href="assets/css/font-awesome.min.css" />
	<!-- 日期 -->
	<link rel="stylesheet" href="assets/css/bootstrap-datepicker.css" />
	<!-- 下拉框 -->
	<link rel="stylesheet" href="assets/css/chosen.css" />
</head>
<body>
	<form id="addForm" action="agent/agent_save.do" method="post">
		<div class="alert alert-info" style="margin-top:2px;margin-bottom:5px;height:40px;padding-top:10px;padding-bottom:10px;">
			<i class="icon-hand-right"></i>注意：标*的字段为必填项！
		</div>
		<table style="width:100%;border-collapse:separate;border-spacing:5px;">
			<tr>
				<td>供应商名称</td>
				<td><input type="text" name="companyName"  id="companyName" maxlength="32"  class="col-xs-10 col-sm-5"/>&nbsp;<span style="color: red">*</span></td>
			</tr>
			<tr>
				<td>法人</td>
				<td><input type="text" name="legalPerson"  id="legalPerson" maxlength="32"  class="col-xs-10 col-sm-5"/>&nbsp;<span style="color: red">*</span></td>
			</tr>
			<tr>
				<td>供应商地址</td>
				<td><input type="text" name="companyAddress"  id="companyAddress" maxlength="32"  class="col-xs-10 col-sm-5"/>&nbsp;<span style="color: red">*</span></td>
			</tr>
			<tr>
				<td>供应商手机号</td>
				<td><input type="text" name="companyPhone"  id="companyPhone" maxlength="32" onblur="companyPhoneOnblur();" class="col-xs-10 col-sm-5"/>&nbsp;<span style="color: red">*</span></td>
			</tr>
			<tr>
				<td>联系人</td>
				<td><input type="text" name="contactPeople"  id="contactPeople" maxlength="32"  class="col-xs-10 col-sm-5"/>&nbsp;<span style="color: red">*</span></td>
			</tr>
			<tr>
				<td>联系手机号</td>
				<td><input type="text" name="contactPhone"  id="contactPhone" maxlength="32" onblur="contactPhoneOnblur();" class="col-xs-10 col-sm-5"/>&nbsp;<span style="color: red">*</span></td>
			</tr>
			<tr>
				<td>联系人邮箱</td>
				<td><input type="text" name="contactEmail"  id="contactEmail" maxlength="32" onblur="contactEmailOnblur();"  class="col-xs-10 col-sm-5"/>&nbsp;<span style="color: red">*</span></td>
			</tr>
			<tr>
				<td>签约开始时间</td>
				<td><input type="text" name=startTime id="startTime"  data-format="yyyy-MM-dd" class="date-picker col-xs-10 col-sm-5" >&nbsp;<span style="color: red">*</span></td>
			<tr>
			<tr>
				<td>合约结束时间</td>
				<td><input type="text" name=endTime id="endTime" data-format="yyyy-MM-dd" class="date-picker col-xs-10 col-sm-5" >&nbsp;<span style="color: red">*</span></td>
			</tr>
			<tr>
				<td style="float:center;text-align:center;height:60px;" colspan="2">
					<button type="button" onclick="saveBattery();" class="btn btn-info btn-sm "><i class="icon-edit bigger-120">&nbsp;&nbsp;</i>提交</button>
					<button type="button" onclick="top.Dialog.close();" class="btn btn-info btn-sm "><i class="icon-lightbulb bigger-120">&nbsp;&nbsp;</i>取消</button>
				</td>
			</tr>
		</table>
	</form>
<script type="text/javascript" src="assets/js/jquery-1.10.2.min.js"></script>
	<!-- 引入 -->
	<script type="text/javascript" src="assets/js/bootstrap.min.js"></script>
	<!-- 下拉框 -->
	<script type="text/javascript" src="assets/js/chosen.jquery.min.js"></script>
	
	<!--提示框-->
	<script type="text/javascript" src="assets/js/jquery.tips.js"></script>
	<!-- 日期 -->
<script type="text/javascript"
	src="assets/js/date-time/bootstrap-datepicker.js"></script>
<script type="text/javascript"
	src="assets/js/date-time/locales/bootstrap-datepicker.zh-CN.js"></script>
	<script type="text/javascript">
	
		$(function() {
			$("table tr").find("td:eq(0)").width(120);
			$('.date-picker').datepicker({
                language: 'zh-CN',
                autoclose: true,
                todayHighlight: true,
                format:"yyyy-mm-dd"
            });
		});

		 function companyPhoneOnblur(){
			 	var inp = document.getElementById("companyPhone");
				var reg = /^(13[0-9]|15[012356789]|17[678]|18[0-9]|14[57])[0-9]{8}$/;
				var result = reg.test(inp.value);
				if (!result) {
					$("#companyPhone").tips({
						side : 1,
						msg : '手机号格式不对，请重新输入!',
						bg : '#0099FF',
						time : 3
					});
					return false;
				}
		}
		 function contactPhoneOnblur(){
			 	var inp = document.getElementById("contactPhone");
				var reg = /^(13[0-9]|15[012356789]|17[678]|18[0-9]|14[57])[0-9]{8}$/;
				var result = reg.test(inp.value);
				if (!result) {
					$("#contactPhone").tips({
						side : 1,
						msg : '手机号格式不对，请重新输入!',
						bg : '#0099FF',
						time : 3
					});
					return false;
				}
		} 
		 function contactEmailOnblur(){
			var inp = document.getElementById("contactEmail");
			var reg = /^(\w-*\.*)+@(\w-?)+(\.\w{2,})+$/;
			var result = reg.test(inp.value);
			if (!result) {
				$("#contactEmail").tips({
					side : 1,
					msg : '邮箱格式不对，请重新输入!',
					bg : '#0099FF',
					time : 3
				});
				return false;
			}
		}
		function saveBattery() {
			if ($("input[name='companyName']").val() == "") {
				showTips($("input[name='companyName']"), '请填写供应商名称！');
				return false;
			}
			if ($("input[name='legalPerson']").val() == "") {
				showTips($("input[name='legalPerson']"), '请填写法人！');

				return false;
			}
			if ($("input[name='companyAddress']").val() == "") {
				showTips($("input[name='companyAddress']"), '请填写供应商地址！');
				return false;
			}
			if ($("input[name='companyPhone']").val() == "") {
				showTips($("input[name='companyPhone']"), '请填写供应商手机号！');
				return false;
			}
			if ($("input[name='contactPeople']").val() == "") {
				showTips($("input[name='contactPeople']"), '请填写联系人！');
				return false;
			}
			if ($("input[name='contactPhone']").val() == "") {
				showTips($("input[name='contactPhone']"), '请填写联系手机号！');
				return false;
			}
			if ($("input[name='contactEmail']").val() == "") {
				showTips($("input[name='contactEmail']"), '请填写联系人邮箱！');
				return false;
			}
				var companyPhone = document.getElementById("companyPhone");
				var reg = /^(13[0-9]|15[012356789]|17[678]|18[0-9]|14[57])[0-9]{8}$/;
				var result = reg.test(companyPhone.value);
				if (!result) {
					$("#companyPhone").tips({
						side : 1,
						msg : '手机号格式不对，请重新输入!',
						bg : '#0099FF',
						time : 3
					});
					return false;
				}
				var contactPhone = document.getElementById("contactPhone");
				var reg = /^(13[0-9]|15[012356789]|17[678]|18[0-9]|14[57])[0-9]{8}$/;
				var result = reg.test(contactPhone.value);
				if (!result) {
					$("#contactPhone").tips({
						side : 1,
						msg : '手机号格式不对，请重新输入!',
						bg : '#0099FF',
						time : 3
					});
					return false;
				}
				var contactEmail = document.getElementById("contactEmail");
				var reg = /^(\w-*\.*)+@(\w-?)+(\.\w{2,})+$/;
				var result = reg.test(contactEmail.value);
				if (!result) {
					$("#contactEmail").tips({
						side : 1,
						msg : '邮箱格式不对，请重新输入!',
						bg : '#0099FF',
						time : 3
					});
					return false;
				}
			$("#addForm").submit();
		};
		function showTips(obj, tips) {
			obj.tips({
				side : 3,
				msg : tips,
				bg : '#e69138',
				time : 2
			});
		}
		var a = new Date();
		var month = a.getMonth()+1;
		if(month<10){
			month = "0" +month;
		}

		var day = a.getDate();
		if(day<10){
			day = "0" + day;
		}

		var hours = a.getHours();
		if(hours < 10){
			hours = "0"+hours;
		}

		var minutes = a.getMinutes()
		if(minutes<10){
			minutes = "0" + minutes;
		}
		$("#startTime").val(a.getFullYear()+"-"+month+"-"+day+" "+hours+":"+minutes);
		$("#endTime").val(a.getFullYear()+"-"+month+"-"+day+" "+hours+":"+minutes);
	</script>
</body>
</html>